#version 330 core

#define EGL_VERTEX_SHADER_POSITION          0
#define EGL_VERTEX_SHADER_TEXCOORD          1
#define EGL_VERTEX_SHADER_NORMAL            2
#define EGL_VERTEX_SHADER_COLOR             3

#define EGL_FRAGMENT_SHADER_TEXCOORD        0

uniform vec4 drawArea;
uniform vec2 charSize;
uniform usampler1D text;

layout(location = EGL_VERTEX_SHADER_POSITION) in vec3 vertPosition;
layout(location = EGL_VERTEX_SHADER_TEXCOORD) in vec2 vertTexCoord;

layout(location = EGL_FRAGMENT_SHADER_TEXCOORD) out vec2 fragTexCoord;

float offsetX = drawArea.x, offsetY = drawArea.y;

void main() {
	fragTexCoord = vertTexCoord;
	gl_Position = vec4(offsetX, offsetY, 0.0, 1.0);
	offsetX += charSize.x;
	if (offsetX + charSize.x > drawArea.z) {
		offsetX = drawArea.x;
		offsetY += charSize.y;
	}
}